package com.web.productservice.controller;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.web.productservice.entity.Product;
import org.springframework.http.ResponseEntity;

/**
 * 异常处理类
 */
public class ExceptionHandler {

    /**
     * 自定义流控处理方法
     */
    public static String handleHello(BlockException ex){
        return "这是Hello接口被限流了";
    }

    public static ResponseEntity<Product> handleProduct(Integer id,
                                                        BlockException ex){
        Product product = new Product();
        product.setName("这是被限流的商品数据");
        return ResponseEntity.ok(product);
    }
}
